# coding=utf-8
# Date: 2021/9/10 9:47
from typing import List


# 执行用时：96 ms, 在所有 Python3 提交中击败了26.44%的用户
# 内存消耗：25.3 MB, 在所有 Python3 提交中击败了29.80%的用户
class Solution:
    def chalkReplacer(self, chalk: List[int], k: int) -> int:
        sum = 0
        for x in chalk:
            sum += x
        k %= sum
        for i in range(len(chalk)):
            if k < chalk[i]:
                return i
            k -= chalk[i]
        return -1


if __name__ == "__main__":
    pass
